package com.google.code.afreechartapp.iris;

import org.afree.chart.demo.DemoView;

import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.google.code.afreechartapp.iris.R;

public class IRISDataMultiViewer extends IRISBase {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.iris_data_multi_viewer);
        
        DemoView view = (DemoView)findViewById(R.id.multi_viewer_demo_view1);
        view.setChart(createChart(AxisType.PetalWidth.ordinal(), AxisType.PetalLength.ordinal()));
        
        view = (DemoView)findViewById(R.id.multi_viewer_demo_view2);
        view.setChart(createChart(AxisType.PetalWidth.ordinal(), AxisType.SepalWidth.ordinal()));
        
        view = (DemoView)findViewById(R.id.multi_viewer_demo_view3);
        view.setChart(createChart(AxisType.PetalWidth.ordinal(), AxisType.SepalLength.ordinal()));
        
        view = (DemoView)findViewById(R.id.multi_viewer_demo_view4);
        view.setChart(createChart(AxisType.PetalLength.ordinal(), AxisType.SepalWidth.ordinal()));
        
        view = (DemoView)findViewById(R.id.multi_viewer_demo_view5);
        view.setChart(createChart(AxisType.PetalLength.ordinal(), AxisType.SepalLength.ordinal()));
        
        view = (DemoView)findViewById(R.id.multi_viewer_demo_view6);
        view.setChart(createChart(AxisType.SepalWidth.ordinal(), AxisType.SepalLength.ordinal()));
    }
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
      MenuInflater inflater = getMenuInflater();
      inflater.inflate(R.menu.iris_data_multi_viewer_menu, menu);
      return true;
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case R.id.menu_about:
            showAbout();
            break;
        case R.id.menu_run_single_viewer:
            Intent intent = new Intent(this, IRISDataViewer.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
            break;
        default:
            throw new IllegalArgumentException("unknown menu id.");
        }
        return true;
    }
}